/*-------------------------------------------------------------------------
 *
 * blcost.c
 *		Bloom 索引的成本估算函数。
 *
 * Copyright (c) 2016-2022, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
 *	  contrib/bloom/blcost.c
 *
 *-------------------------------------------------------------------------
 */
#include "postgres.h"

#include "bloom.h"
#include "fmgr.h"
#include "utils/selfuncs.h"

/*
 * 估算区块索引扫描的成本。
 */
void blcostestimate(PlannerInfo *fc_root, IndexPath *fc_path, double fc_loop_count,
			   Cost *fc_indexStartupCost, Cost *fc_indexTotalCost,
			   Selectivity *fc_indexSelectivity, double *fc_indexCorrelation,
			   double *fc_indexPages)
{
	IndexOptInfo *fc_index = fc_path->indexinfo;
	GenericCosts fc_costs;

	MemSet(&fc_costs, 0, sizeof(fc_costs));

	/* 我们必须访问所有的索引元组 */
	fc_costs.numIndexTuples = fc_index->tuples;

	/* 使用通用估算 */
	genericcostestimate(fc_root, fc_path, fc_loop_count, &fc_costs);

	*fc_indexStartupCost = fc_costs.indexStartupCost;
	*fc_indexTotalCost = fc_costs.indexTotalCost;
	*fc_indexSelectivity = fc_costs.indexSelectivity;
	*fc_indexCorrelation = fc_costs.indexCorrelation;
	*fc_indexPages = fc_costs.numIndexPages;
}
